﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <link href="./css/tie.css" rel="stylesheet" type="text/css" />
    <title>Página de Entidades</title>

    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAPneRrqoFJYtoXfLD7_FUrRStiCTCFzh5HXXdOyPR0BTha56GqBQ6InazaalFgP8mzMGMErF_cMeOZA"
        type="text/javascript"></script>

    <script type="text/javascript" src="scripts/MapEntities.js"></script>

</head>
<body onload="initialize()" onunload="GUnload()">
    <table id="form_canvas" class="MyMatrix_canvas">
        <tr>
            <td>
                <!-- HEADER CONTENT /-->
                <table id="MyMatrix_header" class="MyMatrix_header">
                    <!-- First header table row /-->
                    <tr>
                        <td id="MyMatrix_headerDate">
                            <div id="MyMatrix_header_currentdate">
                                <script type="text/javascript" src="scripts/date.js"></script>
                            </div>
                        </td>
                        <td id="MyMatrix_tracker">
                            <script src="scripts/writePath.js" type="text/javascript"></script>
                            <div style="float: right;">
                                <a href="{{ URL }}">{{ URL_LinkText }}</a> {{User.nickname}}{{user}}</div>
                        </td>
                    </tr>
                    <!-- Second header table row /-->
                    <tr>
                        <td>
                            <div style="float: left;">
                                <img alt="" src="images/TieLogo.png" class="Logo" /></div>
                        </td>
                        <td>
                            <table class="boxNav" border="0" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td class="celNavLeft">
                                    </td>
                                    <td width="10px">
                                        &nbsp;
                                    </td>
                                    <td id="MyMatrix_menu_1" class="celNavMenu">
                                        <a href="/loadactivities">Actividades</a>
                                    </td>
                                    <td width="50">
                                        &nbsp;
                                    </td>                                    
                                    <td id="Td2" class="celNavMenu">
                                        <a href="/loadroutes">Rotas</a>
                                    </td>                                              
                                    <td width="10">
                                        &nbsp;
                                    </td>
                                    <td id="MyMatrix_menu_2" class="celNavMenu">
                                        <a href="/loadentities">Entidades</a>
                                    </td>
                                    <td width="10">
                                        &nbsp;
                                    </td>
                                    <td id="MyMatrix_menu_3" class="celNavMenu">
                                        <a href="/loadcontacts">Contactos</a>
                                    </td>
                                    <td width="10">
                                        &nbsp;
                                    </td>
                                    <td class="celNavRight">
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
                <!-- BODY CONTENT /-->
                <table id="MyMatrix_body" class="MyMatrix_body">
                    <tr>
                        <td>
                            <div id="content">
                                <table>
                                    <tr>
                                        <td valign="top">
                                            <span class="title">Lista de entidades</span>
                                            <br /><br />
                                            <span class="titleHighlight">Use esta página para consultar, criar, alterar ou remover entidades.</span>
                                            <br /><br />
                                        </td>
                                    </tr>
                                </table>
                                <table border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td class="celSepHColorLeft"/>
                                        <td class="celSepHColorCenter"/>
                                        <td class="celSepHColorRight"/>
                                    </tr>
                                </table>
                                {% if EntitiesCount %} 
                                <table class="ListTable">
                                    <tr>
                                        <th>Editar</th>
                                        <th>Entidade</th>
                                        <th>Nome</th>
                                        <th>Distrito</th>
                                        <th>Telefone</th>
                                        <th>Email</th>
                                        <th>URL</th>
                                        <th>Responsável</th>                                    
                                    </tr>
                                    {% for CurrEntity in Entities %}
                                    <tr>
                                        <td><a class="MyLink" href="/loadentities?id={{CurrEntity.key.id}}">editar</a></td>
                                        <td>{{CurrEntity.EntityAbbr}}</td>
                                        <td>{{CurrEntity.EntityName}}</td>
                                        <td>{{CurrEntity.City}}</td>
                                        <td>{{CurrEntity.Phone}}</td>
                                        <td><a class="MyLink" class="Email" href="mailto:{{CurrEntity.Email}}">Email</a></td>
                                        <td>{% if CurrEntity.URL %} <a href="{{CurrEntity.URL}}">{{CurrEntity.URL}}</a> {% endif %}</td>
                                        <td>{{CurrEntity.Responsible}}</td>                                    
                                    </tr>
                                    {% endfor %}
                                </table>
                                <hr />
                                <p style="text-align:right; font-size:smaller">
                                    Número total de entidades: {{EntitiesCount}}
                                </p>
                                {% endif %}                                                                
                                <div class="headline">
                                    <p class="subtitle">Criar/editar entidades</p> </div>
                                {% if user %}
                                <form style="width:100%" action="{{Action}}" method="post" id="formEntity">
                                <table class="EditTable">
                                    <tr>
                                        <td class="EditTable_Col1"><label for="EntityAbbr">Entidade</label></td>
                                        <td class="EditTable_Col2"><input class="EditField" type="text" name="EntityAbbr" id="EntityAbbr" value="{{edEntity.EntityAbbr}}"/></td>
                                        <td class="EditTable_Col3"><label for="EntityName">Nome</label></td>
                                        <td class="EditTable_Col4"><input class="EditField" type="text" name="EntityName" id="EntityName" value="{{edEntity.EntityName}}"/></td>
                                        <td rowspan="6" class="EditTable_Col5">
                                        Responsável: {{edEntity.Responsible}} <br /><br />
                                        Criado por: {{edEntity.CreatedBy}} <br />
                                        Data de criação: {{edEntity.CreatedOn|date:"d.m.Y"}} <br /><br />
                                        Actualizado por: {{edEntity.UpdatedBy}} <br />
                                        Data de actualização: {{edEntity.UpdatedOn|date:"d.m.Y"}}
                                        {% if EditMode %} 
                                            <br /><br />
                                            <a class="MyLink" href="/loadrelationships?ent_id={{edEntity.key.id}}&ent_type=Entity" runat="server">Contactos associados</a>                                        
                                        {% endif %}  
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="EditTable_Col1" valign="top">
                                            <label for="EntityAddress1">Morada</label>
                                        </td>
                                        <td class="EditTable_Col2" colspan="2"><input class="EditField" type="text" name="Address1" id="Address1" value="{{edEntity.Address1}}"/><br />
                                            <label for="PostalCode">CP</label>
                                            <input class="EditField" style="width:70px" type="text" name="PostalCode" id="PostalCode" value="{{edEntity.PostalCode}}"/>                                            
                                            <input class="EditField" style="width:135px" type="text" name="City" id="City" value="{{edEntity.City}}"/>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="EditTable_Col1"><label for="EntityAddress2">País</label></td>
                                        <td class="EditTable_Col2" colspan="1"><input class="EditField" type="text" name="Address2" id="Address2" value="{{edEntity.Address2}}"/></td>
                                    </tr>                                        
                                    <tr>
                                        <td class="EditTable_Col1"><label for="Phone">Telefone</label></td>
                                        <td class="EditTable_Col2" colspan="1"><input class="EditField" type="text" name="Phone" id="Phone" value="{{edEntity.Phone}}"/></td>                                        
                                    </tr>                                    
                                    <tr>
                                        <td class="EditTable_Col1"><label for="Fax">Fax</label></td>
                                        <td class="EditTable_Col2" colspan="1"><input class="EditField" type="text" name="Fax" id="Fax" value="{{edEntity.Fax}}"/></td>                                        
                                    </tr>                         
                                    <tr>
                                        <td class="EditTable_Col1"><label for="Email">Email</label></td>
                                        <td class="EditTable_Col2" colspan="2"><input class="EditField" type="text" name="Email" id="Email" value="{{edEntity.Email}}"/></td>                                        
                                    </tr>                                                                                   
                                    <tr>
                                        <td class="EditTable_Col1"><label for="URL">URL</label></td>
                                        <td class="EditTable_Col2" colspan="2"><input class="EditField" type="text" name="URL" id="URL" value="{{edEntity.URL}}"/></td>
                                    </tr>
                                    <tr>
                                        <td class="EditTable_Col1"><label for="LatLng">Lat./Lng.</label></td>
                                        <td class="EditTable_Col2" colspan="2"><input class="EditField" type="text" name="LatLng" id="LatLng" value="{{edEntity.LatLng}}"/></td>
                                    </tr>
                                    <tr>                                        
                                        <td colspan="5" align="right">
                                        {% if EditMode %} 
                                            <input type="submit" value="Actualizar entidade" /><br />
                                            <a href="/deleteentity?id={{edEntity.key.id}}" runat="server">Eliminar</a>
                                        {% else %} 
                                            <input type="submit" value="Criar empresa" />
                                        {% endif%}                                                                                 
                                        </td>
                                    </tr>
                                </table>
                                </form>
                                
                                <!--  INICIO MAPA GOOGLE /-->
                                <div>
                                <table>
                                    <tr>
                                        <td>
                                            <form action="#" onsubmit="setDirections(); return false">
                                                <table>
                                                    <tr>
                                                        <td align="right">
                                                            <input name="submit" type="submit" value="Localiza endereço" />
                                                        </td>
                                                    </tr>
                                                </table>
                                            </form>
                                        </td>
                                    </tr>
                                </table>
                                <br />
                                <table class="directions">
                                    <tr>
                                        <td valign="top">
                                            <div id="map_canvas" style="width: 930px; height: 400px">
                                            </div>
                                        </td>
                                    </tr>
                                </table>                                              
                                </div>
                                <!--  FIM MAPA GOOGLE /-->
                                
                                {% else %} 
                                    Valide-se com o seu login para ver ou manusear as entidades. 
                                {% endif%}
                            </div>
                        </td>
                    </tr>
                </table>
                
                <!-- FOOTER CONTENT -->
                <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr>
                        <td id="Td1" class="MyMatrix_footer">
                                <script src="scripts/PageLayout.js" type="text/javascript"></script>                            
                        </td>
                    </tr>
                </table>
                <!-- BASEBOARD-->
                <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="boxBaseboard">
                    <tr>
                        <td class="baseboard_left">
                            &nbsp;
                        </td>
                        <td class="baseboard_center">
                            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="baseboard_txt">
                                <tr>
                                    <td style="text-align: left; width: 140px;">
                                        <img src="images/IPCALogo.png" alt="IPCA Logo" />
                                    </td>
                                    <td>
                                        <b>(Nuno Queirós - António Antunes - Miguel Barroso)
                                            <br />

                                            <script type="text/javascript" src="./Scripts/Year.js"></script>

                                            © IPCA</b> . Todos os Direitos Reservados.
                                    </td>
                                </tr>
                            </table>
                        </td>
                        <td class="baseboard_right">
                            &nbsp;
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>


</body>
</html>
